package ca.etsmtl.log730.projet2.connectors.clientserver.setup;

import java.io.Serializable;

public class ConnectionData implements Serializable, Comparable<ConnectionData> {

	/**
	 * 
	 */
	private static final long serialVersionUID = 3806515993052353153L;
	private Integer port = 0;
	private String hostname = "null";
	
	public ConnectionData() {
		this(LocalServerData.getStaticHostname(), 0);
	}
	public ConnectionData(String hn, int p) {
		setHostname(hn);
		setPort(p);
	}
	public int getPort() {
		return port;
	}
	public void setPort(int port) {
		this.port = port;
	}
	public String getHostname() {
		return hostname;
	}
	public void setHostname(String hostname) {
		this.hostname = hostname;
	}
	
	public int hashCode() {
		return getPort();
	}
	@Override
	public int compareTo(ConnectionData o) {
		return getPort() - o.getPort();
	}

	
	public boolean equals(ConnectionData cd) {
		return hashCode() == cd.hashCode();
	}
	
	public String toString() {
		return getHostname() +"@" + getPort();
	}
}
